<?php

class HomeController extends Zend_Controller_Action
{

    public function init()
    {
        try{
    		$session = Zend_Registry::get('session');
    		
    		if($session->user['Username'] != ""){ //ako ne e prazna sesijata znaci deka korisnikot e logiran.
    			
    		}        
        	else{        		
    			$this->_helper->redirector('index','login'); //vo sprotivno vrati go na stranata za logiranje.
    		} 
        
        }
        catch (Zend_Exception $e) {  
			echo "Error message: " . $e->getMessage() . "\n";  
        
        }
    }

    public function indexAction()
    {
    try{
    		$session = Zend_Registry::get('session');
    		
    		
    		if($session->user['Username'] != ""){ //ako e prazna sesijata znaci ne e logiran korisnikot    	
    		
	        	//$form_status = new Application_Form_Status();
	        	//$this->view->form_status = $form_status;
	        	
	        	$status = new Application_Model_DbTable_Status();
	        	

	        	$statuses = $status->getStatusesHome($session->user['id']);
    			$this->view->statuses = $statuses;
	        	
    		}
    		else{
    			$this->_helper->redirector('index','login');
    		}   
        	
        
        }
        catch (Zend_Exception $e) {  
			echo "Error message: " . $e->getMessage() . "\n";  
        }
    }


}

